package cn.openea.perpartner.wxpay.controller;

import cn.openea.perpartner.wxpay.service.QueryService;
import cn.openea.perpartner.wxpay.vo.QueryVo;
import cn.openea.perpartner.wxpay.vo.R;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Name: 提供查询各种支付列表
 * @author: Mr.Yun
 * @Created: 2022/10/17 19:44
 */
@Api(tags = "提供查询各种支付列表")
@RestController
@RequestMapping("/api")
public class QueryController {

    @Autowired
    QueryService queryService;

    @ApiOperation("查询统一支付的订单列表")
    @RequestMapping(value = "/getpaylist", method = RequestMethod.POST)
    public R queryPayOrderList(@RequestBody @ApiParam(name = "查询列表统一VO对象", value = "userid必填，其它项都有默认值") QueryVo queryVo) {
        return queryService.queryPayOrderList(queryVo);
    }

    @ApiOperation("查询商户退款的订单列表")
    @RequestMapping(value = "/getrefundlist", method = RequestMethod.POST)
    public R queryRefundOrderList(@RequestBody @ApiParam(name = "查询列表统一VO对象", value = "userid必填，其它项都有默认值") QueryVo queryVo) {
        return queryService.queryRefundOrderList(queryVo);
    }

    @ApiOperation("查询从商户支付零钱到个人的订单列表")
    @RequestMapping(value = "/getchangelist", method = RequestMethod.POST)
    public R queryPayChangeList(@RequestBody @ApiParam(name = "查询列表统一VO对象", value = "userid必填，其它项都有默认值") QueryVo queryVo) {
        return queryService.queryPayChangeList(queryVo);
    }

    @ApiOperation("查询所的订单列表：包含统一支付、商户退款、支付零钱")
    @RequestMapping(value = "/getalllist", method = RequestMethod.POST)
    public R queryAllOrderList(@RequestBody @ApiParam(name = "查询列表统一VO对象", value = "userid必填，其它项都有默认值") QueryVo queryVo) {
        return queryService.queryAllOrderList(queryVo);
    }

    @ApiOperation("依据订单id查询所有订单（包含统一支付、商户退款[tradeNo传refundNo退款单号]、支付零钱）")
    @RequestMapping(value = "/getorderbyid", method = RequestMethod.POST)
    public R queryOrderByID(@RequestParam @ApiParam(name = "tradeNo", required = true, value = "必须，统一支付和支付零钱传tradeNo，商户退款传refundNo") String tradeNo,
                            @RequestParam(required = false) @ApiParam(name = "orderType", value = "非必须，订单类别（统一支付=order，商户退款=refund，支付零钱=change，其它或ALL表示查以上三者中一条记录）") String orderType) {
        return queryService.queryOrderByID(tradeNo, orderType);
    }


}
